chore(dead-code): phase 2 trim pages shim cascade + packages/common monorepo#6
Merged
Merged
Conversation
This was referenced Jun 4, 2026
Agions
added a commit
that referenced
this pull request
Jun 6, 2026
…usiness ## 删除的目录 1. `src/types/` - 整个目录 (1 shim 文件) - `src/types/index.ts` 仅为 `@/shared/types` 的 shim - 仅 2 个文件 import 它, 已改为 `@/shared/types` 2. `src/components/business/` - 整个目录 (4 shim 文件) - `CostDashboard.tsx` / `RenderCenter.tsx` / `CompositionStudio.tsx` / `index.ts` - 全部为 shim 转发到 `@/shared/components/business/...` - 8 个引用方改 import 路径后删除 ## 修改的 import 路径 (10 个文件) - src/features/script/components/ScriptPreview.tsx - src/features/video/components/VideoAnalyzer.tsx - src/features/cost/components/CostPanel.tsx (同时清理 const 别名残留) - src/pages/project-edit/ProjectEditPage.tsx - src/pages/project-edit/components/StepRender.tsx - src/pages/project-edit/components/StepComposition.tsx - src/pages/project-detail/ProjectDetailPage.tsx (3 个 import) - src/__tests__/pages/project-detail.test.tsx (3 个 mock) - src/__tests__/pages/project-edit.test.tsx (1 个 mock) ## 保留 (本轮不做) - `src/components/ui/` (43 个 shim, 改起来风险大, 留 PR #5/#6) - `src/components/business/` 真实实现: 已确认位于 `src/shared/components/business/` ## 验证 - npx tsc --noEmit → 0 错误 - npx jest → 1596/1600 pass (与 main 一致, 0 回归) - npm run build → exit 0 - 90 个测试套件全过 ## 收益 - 净删: 5 个 shim 文件 + 2 个空目录 - 净化: 10 个文件的 import 路径正确指向真实实现位置 - 命名一致性: 业务代码不再使用误导性旧路径 (`@/types` / `@/components/business`)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🐱 Dead Code Cleanup — Phase 2 (radical, ~30 files / -2,586 lines / ~190 KB)
Summary
Continues Phase 1 cleanup. Two unrelated workstreams bundled because they share the same root cause (left-over scaffolding from in-progress refactors that were never finished):
packages/common/monorepo trim — 7 sub-directories with zero project references removed, package pruned to constants-only🅲️ Pages shim cascade
The 4 capital-case
pages/{AutoPipeline,ProjectEdit,ProjectEdit/ScriptDetail,ProjectDetail}/directories were 2-line shims that re-exported the lowercasepages/{auto-pipeline,project-detail,project-edit}/siblings. They existed only to give the router nice PascalCase import paths. Both routers (app/router/page-preload.ts+core/router/page-preload.ts) now use the lowercase canonical paths directly.Deleted (5 files):
src/pages/AutoPipeline/AutoPipelinePage.tsxsrc/pages/ProjectDetail/ProjectDetailPage.tsxsrc/pages/ProjectEdit/ProjectEditPage.tsxsrc/pages/ProjectEdit/ScriptDetailPage.tsxsrc/pages/index.ts(also pointed at shims)Modified:
src/app/router/page-preload.ts— 3 dynamic imports:@/pages/Project{Edit,Detail}/*→@/pages/project-{edit,detail}/*,@/pages/AutoPipeline/*→@/pages/auto-pipeline/*src/core/router/page-preload.ts— same 3 + 1 scriptDetail path🅳️
packages/common/monorepo trimOriginal design (per
docs/adr/0002-frontend-monorepo-ddd.md) was to split the project into a publishable monorepo package withutils/formatters/motion/hooks/components/domain/validationsub-paths. Zero project files actually import any of these — onlyconstantsis referenced (4 sites inMusicTab/SfxTab/audio.entities/VideoExporter). The other 7 sub-directories sat at 192 KB of dead code.Deleted (17 files + 3 empty dirs + 1 README):
packages/common/src/utils/(16 KB)packages/common/src/formatters/(12 KB)packages/common/src/motion/(8 KB)packages/common/src/hooks/(20 KB)packages/common/src/components/ui/{FileUploader,ProgressBar,Modal,ConfirmDialog}.{tsx,module.css}(44 KB)packages/common/src/domain/{character,scene,script,shared,index}.ts(44 KB)packages/common/src/validation/(empty dir)packages/common/eslint-rules/(empty dir)packages/common/tests/(empty dir)packages/common/README-before-after.md(transitional DRY-illustration doc)Modified:
packages/common/src/index.ts— shrunk toexport * from './constants'+ comment explaining the trim and pointing atdocs/adr/0002for original design intentpackages/common/package.json— removed 5 deadexportsentries (./*sub-paths), kept peerDependencies and devDependencies intact for future monorepo resurrection🐛 Two latent bugs exposed (not fixed — out of scope)
Removing the broken
@/pages/ProjectEditPageskip-listing surfaced two pre-existing issues that were hidden behindtestPathIgnorePatternsentries injest.config.cjs. Both are now re-skipped with a more accurate comment so a future "form refactor" PR can pick them up:ProjectEditPage.tsxuseForm API mismatch —const [form] = useForm() as any(line 95) destructures the return value ofuseForm()as a tuple, but the actual export from@/components/ui/ui-componentsisuseRhfForm(react-hook-form) which returns an object. TriggersTypeError: object is not iterable (cannot read property Symbol(Symbol.iterator))at first render. A NOTE comment in the source already flags this as "intentional until form refactor".__tests__/pages/project-{edit,detail}.test.tsximport paths — both used@/pages/ProjectEditPage/@/pages/ProjectDetailPage(no sub-dir, no extension) which never existed as a real module. Fixed to the canonical lowercase paths in this PR so the tests can run, then re-skipped under the new "form refactor" reason.Files re-skipped with new reason in
jest.config.cjs:src/__tests__/pages/project-edit.test.tsxsrc/__tests__/pages/project-detail.test.tsxVerification
npm run lint --quietnpx tsc --noEmitnpm test --runInBand(90 suites)npm run buildDiff
Phase summary
Lesson reinforced
import('@/...')string literals are invisible to staticimportregex sweeps. Phase 1 missed 2 shims (components/business/CompositionStudio+RenderCenter); Phase 2 caught all 4 pages shims because the routers use the same pattern. Thetsc --noEmitsafety net caught the first batch immediately — always run it after everygit rmcycle.testPathIgnorePatternsis a smell audit point — 2 tests in there were broken since v1.x and silently skipped. Dead-code sweeps are a good time to audit ignore lists for stale entries.